home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************\
- * Header Files
- \******************************************************************************/
-
- #include <Controls.h>
- #include <Desk.h>
- #include <Events.h>
- #include <Memory.h>
- #include <Script.h>
- #include <Windows.h>
- #include "CursWindTkl.h"
- #include "ShowCursor.h"
- #include "WindowTkl.h"
-
-
- /******************************************************************************\
- * Constants & Macros
- \******************************************************************************/
-
- #define titleBarHeight 18 //Height of docWindProc title bar in pixels
- #define userWindMarg 50 //User window margin
- #define stdWindMarg 3 //Zoom window margin
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoUpdateEvent - Handles a window update event
- *
- * DoUpdateEvent handles a window update event by drawing the window grow icon.
- \******************************************************************************/
-
- void
- DoUpdateEvent (TheEvent)
- EventRecord *TheEvent; //-> Update event
- {
- WindowPtr UpdtWind; //-> Window to update
- GrafPtr SavePort; //-> Saved port
-
- GetPort (&SavePort);
- UpdtWind = (WindowPtr) TheEvent->message;
- SetPort (UpdtWind);
- BeginUpdate (UpdtWind);
- EraseRect (&UpdtWind->portRect);
- DrawCursWind (UpdtWind);
- EndUpdate (UpdtWind);
- SetPort (SavePort);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoActivateEvent - Handles a window activate event
- *
- * DoActivateEvent handles a window activate event.
- \******************************************************************************/
-
- void
- DoActivateEvent (ActiveWind, Active)
- WindowPeek ActiveWind; //-> Window requiring activation/deactivation >>
- short Active; //True if activating, false if deactivating >>
- {
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoContentEvent - Handle click in the windows content region
- *
- * DoContentEvent handles a click in the content region of the window specified
- * by ClickWind. TheEvent points to the event record that recorded this click.
- \******************************************************************************/
-
- void
- DoContentEvent (TheEvent, ClickWind)
- EventRecord *TheEvent; //-> Drag click event >>
- WindowPtr ClickWind; //-> Clicked window >>
- {
- if (ClickWind != FrontWindow ())
- SelectWindow (ClickWind);
- else if (windKindPtr (ClickWind) == cursWindKind)
- ContentCursWind (TheEvent, ClickWind);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoDragEvent - Handle click in title bar
- *
- * DoDragEvent handles a click in the title bar to drag the window to a new
- * location.
- \******************************************************************************/
-
- void
- DoDragEvent (TheEvent, ClickWind)
- EventRecord *TheEvent; //-> Drag click event
- WindowPtr ClickWind; //-> Clicked window
- {
- Rect LimitRect; //Rect to limit dragging to
- RgnHandle GrayRegion; //=> Desktop gray region
-
- GrayRegion = GetGrayRgn ();
- LimitRect = (**GrayRegion).rgnBBox;
- DragWindow (ClickWind, TheEvent->where, &LimitRect);
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoGoAwayEvent - Handle click in close box
- *
- *
- \******************************************************************************/
-
- void
- DoGoAwayEvent (TheEvent, ClickWind)
- EventRecord *TheEvent; //-> Drag click event >>
- WindowPtr ClickWind; //-> Clicked window <>
- {
- if (TrackGoAway (ClickWind, TheEvent->where))
- {
- if (windKindPtr (ClickWind) == cursWindKind)
- CloseCursWind (ClickWind);
- }
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * DoZoomEvent - Handle click in zoom box
- *
- * DoZoomEvent handles a click in the zoom box of the window specified by
- * ClickWind.
- \******************************************************************************/
-
- void
- DoZoomEvent (TheEvent, ClickWind, PartCode)
- EventRecord *TheEvent; //-> Drag click event >>
- WindowPtr ClickWind; //-> Clicked window <>
- short PartCode; //inZoomIn or inZoomOut >>
- {
- GrafPtr CurrPort; //-> Current GrafPort
-
- if (TrackBox (ClickWind, TheEvent->where, PartCode))
- {
- GetPort (&CurrPort);
- SetPort (ClickWind);
- ZoomWindow (ClickWind, PartCode, true);
- SetPort (CurrPort);
- }
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * CloseAllWindows - Close all open windows
- *
- * CloseAllWindows closes all the open windows.
- \******************************************************************************/
-
- void
- CloseAllWindows ()
- {
- WindowPeek TheWindow; //-> window to close
-
- TheWindow = (WindowPeek) FrontWindow ();
- while (TheWindow != (WindowPeek) null)
- {
- if (windKindPtr (TheWindow) < 0)
- CloseDeskAcc (windKindPtr (TheWindow));
- else if (windKindPtr (TheWindow) == cursWindKind);
- CloseCursWind ((WindowPtr) TheWindow);
- TheWindow = TheWindow->nextWindow;
- }
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * SetWindSize - Set user and standard sizes of window
- *
- * SetWindSize sets the user and standard sizes of the window specified by
- * TheWindow. The userState and stdState rectangles in TheWindow’s WStateData
- * record are set to the main screen rectangle minus the menu bar and a certain
- * amount specified by the userWindMarg and stdWindMarg.
- \******************************************************************************/
-
- void
- SetWindSize (TheWindow)
- WindowPtr TheWindow; //-> Window to resize <>
- {
- Rect WindRect; //Rectangle of windows’s user and standard sizes
- WStateData **WindStates; //=> Window zoom rectangles
-
- WindStates = (WStateData **) ((WindowPeek) TheWindow)->dataHandle;
- WindRect = qd.screenBits.bounds;
- WindRect.top += GetMBarHeight () + titleBarHeight;
- InsetRect (&WindRect, userWindMarg, userWindMarg);
- (**WindStates).userState = WindRect;
- WindRect = qd.screenBits.bounds;
- WindRect.top += GetMBarHeight () + titleBarHeight;
- InsetRect (&WindRect, stdWindMarg, stdWindMarg);
- (**WindStates).stdState = WindRect;
- }
-
-
- #pragma segment Main
- /******************************************************************************\
- * FrontWindKind - Return pointer to frontmost window of a kind
- *
- * FrontWindKind returns a pointer to the frontmost window with a windowKind
- * field equal to WindKind. If there aren't any windows with that windowKind,
- * null is returned.
- \******************************************************************************/
-
- WindowPtr
- FrontWindKind (WindKind)
- short WindKind; //Window kind to search for
- {
- WindowPeek CheckWind; //-> Window to check on
-
- CheckWind = (WindowPeek) FrontWindow ();
- while (CheckWind != (WindowPeek) null && CheckWind->windowKind != WindKind)
- CheckWind = CheckWind->nextWindow;
- return (WindowPtr) CheckWind;
- }
-